﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Collections
{
    public static class TypedStructuralComparisons<T>
    {
        public static IComparer<T> StructuralComparer
        {
            get
            {
                return _Instance.Value;
            }
        }
        public static IEqualityComparer<T> StructuralEqualityComparer
        {
            get
            {
                return _Instance.Value;
            }
        }

        private static Lazy<TypedStructuralComparisonWrapper<T>> _Instance = new Lazy<TypedStructuralComparisonWrapper<T>>( () => new TypedStructuralComparisonWrapper<T>());
    }
    
    internal class TypedStructuralComparisonWrapper<T>
            : IEqualityComparer<T>, IComparer<T>
    {
    #region IEqualityComparer<T> Members

        public bool  Equals(T x, T y)
        {
         	return System.Collections.StructuralComparisons.StructuralEqualityComparer.Equals(x,y);
        }

        public int  GetHashCode(T obj)
        {
         	return System.Collections.StructuralComparisons.StructuralEqualityComparer.GetHashCode(obj);
        }

        #endregion

        #region IComparer<T> Members

        public int  Compare(T x, T y)
        {
         	return System.Collections.StructuralComparisons.StructuralComparer.Compare(x,y);
        }

#endregion
}
}
